package choose;

import java.util.Map;

public class useCycle {
    public static void main(String[] args) {
        //forString();
        //useWhile();
        //useIntReserve01();
        use(50,12);

    }
    // 跟数据类型相结合的使用+明确循环次数的
    public static void forString(){
        String str = "我爱你小同";
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (i==0){
                continue;
            }
            System.out.println(c);
        }
        for (int i = str.length()-1; i >= 0; i--) {
            char c = str.charAt(i);
            System.out.println(c);
        }
    }
    public static void useWhile(){
        double height = 8844430;
        Double paperHeight = 0.1;
        int count = 0;
        while (paperHeight<=height){
            paperHeight = paperHeight*2;
            count++;

        }
        System.out.println(paperHeight);
        System.out.println(count);
    }

    // 回文数，一个整数倒着和正的操作都一样
    public static void useIntReserve(int number) {
        // 数据有一个整数
        int reserveInt = 0;
        String strInt = String.valueOf(number);
        int count = 0;
        for (int i = 0; i < strInt.length(); i++) {
            int c = strInt.charAt(i) - 48;
            reserveInt += c * Math.pow(10, count);
            count++;
        }
        System.out.println(reserveInt);
    }
    // 倒的相等
    public static void useIntReserve01(){
        int x = 1234;
        int num = 0;
        while (x!=0){
            int ge = x%10;
            x = x/10;
            num = num*10 +ge;
        }
        System.out.println(num);
    }
    // 得出商和余数，不要乘除余运算符
    public static void use(int i, int j){
        int count = 0;
        while (i>=j){
           i =  i-j;
           count++;
        }
        System.out.println(count);
        System.out.println(i);
    }
}


